<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<script type="text/javascript">
$(function(){
	$(".datepicker").datepicker({dateFormat:'yy-mm-dd',changeMonth:true});
});
</script>
<fieldset><legend>查询条件</legend>
<form method="get">
<?include(Q::ini('custom_system/elements_dir') . 'searchform_element.php'); ?>
<table class="form_table">
<tr>
	<th>发货日期</th>
	<td colspan="3">
		<input type="text" name="begin_shipped_time" class="datepicker" value="<?=isset($_GET['begin_shipped_time']) ? $_GET['begin_shipped_time'] : ''?>" /> to
		<input type="text" name="end_shipped_time" class="datepicker" value="<?=isset($_GET['end_shipped_time']) ? $_GET['end_shipped_time'] : ''?>" />
	</td>
</tr>
<tr>
	<th>网站/店铺</th>
	<td colspan="3">
		<select name="shop_id">
			<option value="">请选择..</option>
			<?foreach ($shop as $s):?>
			<option value="<?=$s['id']?>" <?if(isset($_GET['shop_id']) && $_GET['shop_id']==$s['id'])echo "selected='selected'"?>><?=$s['name']?></option>
			<?endforeach;?>
		</select>
	</td>
</tr>
<tr>
	<th>本地单号</th>
	<td><input type="text" name="number" value="<?=isset($_GET['number']) ? $_GET['number'] : ''?>" /></td>
	<th>网站单号</th>
	<td><input type="text" name="shop_order_number" value="<?=isset($_GET['shop_order_number']) ? $_GET['shop_order_number'] : ''?>" /></td>
</tr>
<tr>
	<th>买家全名</th>
	<td><input type="text" name="fullname" value="<?=isset($_GET['fullname']) ? $_GET['fullname'] : ''?>" /></td>
	<th>物流追踪号</th>
	<td><input type="text" name="tracking_number" value="<?=isset($_GET['tracking_number']) ? $_GET['tracking_number'] : ''?>" /></td>
</tr>
<tr>
	<th width="60">邮寄方式</th>
	<td colspan="3">
		<table>
		<?foreach ($shipping_method as $sm):?>
		<tr>
			<th><strong><?=$sm['name']?>：</strong></th>
			<td style="padding: 1px;">
				<?foreach ($sm['children'] as $v):?>
				<label style="float: left;"><input type="checkbox" name="shipping_method[<?=$v['id']?>]" value="<?=$v['id']?>" <?if (isset($_GET['shipping_method']) && array_key_exists($v['id'], $_GET['shipping_method'])) echo "checked='checked'"?> /> <?=$v['name']?>&nbsp;</label>
				<?endforeach;?>
			</td>
		</tr>
		<?endforeach;?>
		</table>
	</td>
</tr>
<tr>
	<th>追踪号</th>
	<td colspan="3">
		<label><input type="checkbox" name="is_tracking_number[1]" value="1" <?if(isset($_GET['is_tracking_number']) && array_key_exists(1, $_GET['is_tracking_number'])) echo "checked='checked'"?> /> 无</label>
		<label><input type="checkbox" name="is_tracking_number[2]" value="2" <?if(isset($_GET['is_tracking_number']) && array_key_exists(2, $_GET['is_tracking_number'])) echo "checked='checked'"?> /> 有</label>
	</td>
</tr>
<tr>
	<td></td>
	<td><input type="submit" class="button" value="查询" /></td>
</tr>
</table>
</form>
</fieldset>
<table width="100%" class="list_table">
<tr>
	<th width="100">本地单号</th>
	<th width="150">网站单号</th>
	<th>网站/店铺</th>
	<th width="130">发货日期</th>
	<th width="150">买家全名</th>
	<th width="130">追踪号</th>
	<th width="160">物流处理号</th>
</tr>
<?foreach ($order as $o):?>
<tr height="35">
	<td><?=$o['number']?></td>
	<td><?=$o['shop_order_number']?></td>
	<td><?=$o['shop_name']?></td>
	<td><?=$o['shipped_time']?></td>
	<td><?=$o['fullname']?></td>
	<td><?=$o['tracking_number']?></td>
	<td><?=$o['lsp_number']?></td>
</tr>
<?endforeach;?>
</table>
<?=$page?>
<?if (isset($postage)):?>
<?$weight = $postage_amount_cny = 0;?>
<?$postage_amount = array();?>
<?foreach ($postage as $p):?>
<?$weight += $p['weight'];?>
<?$postage_amount_cny += $p['postage_amount_cny'];?>
<?$postage_amount[] = '<strong>' . $p['code'] . '：</strong>' . (isset($p['postage_amount']) ? sprintf('%.2f', $p['postage_amount']) : '0.00');?>
<?endforeach;?>
搜索条件总重量：<strong><?=sprintf('%.3f', $weight/1000)?> KG</strong><br />
搜索条件总物流费用：<?=implode(' + ', $postage_amount) . ' = <strong>CNY：</strong>' . sprintf('%.2f', $postage_amount_cny);?>
<?endif;?>
<?php $this->_endblock(); ?>